﻿using Microsoft.EntityFrameworkCore;
using OrderApi.Models;

namespace OrderApi.Data
{
    public class AppDbContext : DbContext
    {
        public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }

        public DbSet<Order> Orders { get; set; }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            //modelBuilder.Entity<Order>().Property(o => o.TotalAmount).HasColumnType("decimal(18,2)");
            modelBuilder.Entity<Order>(entity =>
            {
                // ...现有配置...
                entity.Property(o => o.TotalAmount).HasColumnType("decimal(18,2)");
                // 添加假删除查询过滤器
                entity.HasQueryFilter(o => !o.IsDeleted);
            });
        }
    }
}
